<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




<title>Spring.NET框架简介及模块说明 - Accumulating - 博客园</title>
<meta name="keywords" content="Spring.NET框架简介及模块说明">



<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/pursue/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/pursue/rsd.xml"> 
  



<link rel="stylesheet" type="text/css" href="index.css" media="all">
</head>
<body>
    <form name="Form1" method="post" action="http://www.cnblogs.com/pursue/articles/1595059.html" id="Form1">
<div>
<input name="__EVENTTARGET" id="__EVENTTARGET" value="" type="hidden">
<input name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" type="hidden">
<input name="__VIEWSTATE" id="__VIEWSTATE" value="" type="hidden">
</div>




        
<!--done-->
<div id="home">
<div id="header">
	<div id="blogTitle">
	<a id="lnkBlogLogo" href="http://www.cnblogs.com/pursue/"><img id="blogLogo" src="logo.gif" alt="返回主页"></a>			
		
<!--done-->
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/pursue/">Accumulating</a></h1>
<h2></h2>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<!--done-->
			<ul id="navList">
				<li><a id="MyLinks1_HomeLink" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
				<li><a id="MyLinks1_SpaceLink" class="menu" href="http://space.cnblogs.com/">社区</a></li>
				<li><a id="MyLinks1_MyHomeLink" class="menu" href="http://www.cnblogs.com/pursue/">首页</a></li>
				<li><a id="MyLinks1_NewPostLink" class="menu" href="http://www.cnblogs.com/pursue/admin/EditPosts.aspx?opt=1">新随笔</a></li>
				<li><a id="MyLinks1_ContactLink" accesskey="9" class="menu" href="http://space.cnblogs.com/msg/send/pursue">联系</a></li>
				<li><a id="MyLinks1_Admin" class="menu" href="http://www.cnblogs.com/pursue/admin/EditPosts.aspx">管理</a></li>
				<li><a id="MyLinks1_Syndication" class="menu" href="http://www.cnblogs.com/pursue/rss">订阅</a>
				<a id="MyLinks1_XMLLink" class="aHeaderXML" href="http://www.cnblogs.com/pursue/rss"><img src="rss.gif" alt="订阅" style="border-width: 0px;"></a></li>
			</ul>


		<div class="blogStats">
			
			
<!--done-->
随笔- 92&nbsp;
文章- 125&nbsp;
评论- 0&nbsp;

			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->

<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
					
<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="ctl04_TitleUrl" class="postTitle2" href="http://www.cnblogs.com/pursue/articles/1595059.html">Spring.NET框架简介及模块说明</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<p><a href="http://www.cnblogs.com/beniao/archive/2008/04/22/Springnet.html">Spring.net(一)----Spring.NET框架简介及模块说明</a></p>  <p>简介:   <br>&nbsp;&nbsp;&nbsp; Spring.NET框架包括很多功能,Spring.NET 1.0包括完整的IoC容器和AOP类库。1.1版加入Web、ORM和数据模块。Spring.NET的下载包中并不包含与其它类库（如NHibernate，TIBCO EMS，Anthem，和IIOP.NET）集成的模块，如果需要您可以单独下载。    <br>&nbsp;&nbsp;&nbsp; Spring Framework天生丽质，因为其先进的架构和对一系列前沿开发思想的集成，使它从一产生就深得开发者欢迎，它将设计模式运用到了炉火纯青的地方，它的幽雅和魅力征服了许多JAVA开发者，使这些开发者成为了它的信徒，得程序员心者得天下，Spring引领了J2EE开发的潮流，同时Spring和各种框架的强强联手也为它的信徒的尽早飞翔插上了翅膀，比如老大哥SSH（配置烦琐的struts和Hibernate、Spring的集成）、后起之秀EJSA（身材轻便使用灵活及零配置的EASYJWEB+JPA+Spring+Acegi，适合与注重高效率开发的个人和企业）等都借助Spring走向了成熟，为开发者带来了无尽方便。    <br>&nbsp;&nbsp;&nbsp;&nbsp; 那么做为.Net开发者我们能不能欣赏和品尝Spring这道大餐呢，答案是肯定的，Spring开发团队对应用与JAVA的Spring框架思想进行移植，贡献出了适合与.Net项目开发的Spring.NET框架。网上Spring.Net的中文资料很少，在BAIDU上目前搜索不到关于spring.net的中文资料，这里我们尽可能的使用中文来说明。    <br>首先我们来认识一下Spring.NET,简而言之Spring.NET就是利用各种强大的设计模式做为工具来管理我们的项目体系结构。 Spring.NET使用优秀和久经考验的设计模式，使我们能够科学合理的管理和整合我们企业级开发中的各个层面及一些分散的组件,并良好的协调和处理它们之间的关系，增强项目的健壮性。    <br>&nbsp;&nbsp;&nbsp; Spring.NET的IoC容器所解决的，正是如何在企业应用中将类、对象和服务组合成应用程序的问题。IoC容器通过很正统（按：formalized，言下之意是这些方式都是已经定型了的、经过了业界多年考验的）的方式将分散的组件组合成完整的应用程序。Spring.NET框架所采用的，都是被业界无数应用程序考验多年的、已经被定型为设计模式的最佳编程方式，实际上，这些模式已经成为我们架构和开发时的法典，而通过Spring.NET，我们可以直接将它们整合到自己的应用程序中。目前已有很多组织和机构用Spring框架开发出了强壮的、维护性好的应用程序，这确实是一件非常好的事情。    <br>模块说明:    <br><img alt="" src="spring.jpg" border="0" height="337" width="544">    <br><em>一.Spring.Core</em>作为整个框架的基础，实现了依赖注入的功能。    <br>&nbsp;&nbsp; Spring.NET的大部分模块都要依赖或扩展该模块。Spring.Core的基础是IObjectFactory接口，该接口用一个简单而    <br>&nbsp;&nbsp; 优雅的方式实现了工厂模式，使我们可以无需自行编写singleton类型和众多的服务定位器，并允许将对象配置及其依    <br>&nbsp;&nbsp; 赖关系与具体的程序逻辑解耦。该模块中的IApplicationContext接口是IObjectFactory的扩展，增加了诸多企业级    <br>&nbsp;&nbsp; 功能，包括使用资源文件进行文本本地化、事件传播和资源装载等等。    <br><em>二.Spring.AOP</em>为业务对象提供面向方面编程（AOP）的支持。    <br>&nbsp;&nbsp; AOP完善了IoC容器的功能，为创建企业应用和使用声明式服务奠定了坚实的基础。    <br>三.<em>Spring.Web</em>对ASP.NET进行了一系列功能扩展，包括对ASP.NET页面进行依赖注入、双向数据绑定、在ASP.NET 1.1中    <br>&nbsp;&nbsp; 使用Master page、以及增强的本地化功能支持等。    <br>四.<em>Spring.Services</em>允许将任意的“普通”对象（意为没有继承任何指定基类型的对象）发布为企业服务（COM+）或远程    <br>&nbsp;&nbsp; 对象。    <br>&nbsp;&nbsp; 通过依赖注入和特性元数据覆盖等功能，该模块可使.NET的Web服务获得极大的灵活性。同时也支持Windows后台服务。    <br>五.<em>Spring.Data</em>定义了一个抽象的数据访问层，可以跨越各种数据访问技术（从ADO.NET到各种ORM）进行数据访问。    <br>&nbsp;&nbsp; 该模块包含一个ADO.NET的抽象层，减少了使用传统ADO.NET进行编码和事务管理时的工作量。    <br>六.<em>Spring.ORM</em>为时下流行的ORM类库提供了一个整合层，其中包含声明式事务管理等诸多功能。</p>  <p></p>  <p><a href="http://www.cnblogs.com/beniao/archive/2008/04/22/974930.html">Spring.net(二)----初探IOC容器</a></p>  <p>&nbsp;&nbsp;&nbsp; 我在上一篇关于Spring.net的文章“<a href="http://www.cnblogs.com/beniao/archive/2007/11/23/Springnet.html">Spring.NET框架简介及模块说明</a> ”中很详细的介绍了，本文就不旧话从提。我门就直奔主题吧。    <br>1.首先了解两个接口.    <br>&nbsp; IObjectFactory接口和IApplicationContext接口:他两个称为“容器”或“IOC容器”。    <br>&nbsp; Spring.net框架的核心原则是非侵入性。    <br>&nbsp; IObjectFactory接口是初始化、配置及管理对象的实际容器。    <br>&nbsp; IObjectFactory全限定名为Spring.Objects.Factory.IObjectFactory,IObjectFactory接口有多个实现，其中最    <br>&nbsp; 常用的是Spring.Objects.Factory.XML.XmlObjectFactory。    <br>2.对象定义的XML文件    <br>&nbsp; 在app.config或是web.config中加入    <br>&nbsp; &lt;spring&gt;    <br>&nbsp;&nbsp;&nbsp; &lt;context type="Spring.Context.Support.XmlAppliationContext",Spring.Core"/&gt;    <br>&nbsp;&nbsp;&nbsp; &lt;resource uri=<a href="file://objects.xml/">file://objects.xml/</a>/&gt;    <br>&nbsp; &lt;/spring&gt;    <br>&nbsp; 注意：context的type属性是可以省略的。    <br>3.spring和context的顺序是有限制的，在Spring.net框架里已经将“spring/context”作为字符串常量定义在了    <br>&nbsp; AbstractApplicationContext类中以来表示上下文的接点名称。可通过：    <br>&nbsp; IApplicationContext context=ContextRegistry.GetContext();来获取接点值，这里要注意一点。在使用他的    <br>&nbsp; 时候必须要使配置文件中的&lt;spring&gt;接点起作用，这样就得必须在.NET的配置文件&lt;configSections&gt;节点下注册类    <br>&nbsp; Spring.Context.Support.ContextHandler,它让ContextRegistry类可用来初始化应用程序上下文，它实现在FCL    <br>&nbsp; 的IConfigurationSectionHandler接口    <br>3.XML对象定义可在&lt;objects&gt;节点注册    <br>&nbsp; &lt;section name="objects" type="Spring.Context.Support.DefultSectionHandler,Spring.Core"&gt;    <br>4.Spring.net的IOC容器的简单实例----用简单三层来实现    <br>&nbsp; 光说这么多没用，我门还是来点实际的，看看下面的这个简单实例：    <br>&nbsp; 一.先建立项目随后添加引用Spring.Core程序集。    <br>&nbsp; 二.引用System.Configuration----需要用到ConfigurationManager类的方法。    <br>&nbsp; 三.配置.NET配置文件----具体配置如下：    <br>&lt;?xml version="1.0" encoding="utf-8" ?&gt;    <br>&nbsp; &lt;configuration&gt;    <br>&nbsp;&nbsp;&nbsp; &lt;configSections&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sectionGroup name="spring"&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;section name="context"    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="Spring.Context.Support.ContextHandler, Spring.Core"/&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;section name="objects"    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/sectionGroup&gt;    <br>&nbsp;&nbsp;&nbsp; &lt;/configSections&gt;    <br>&lt;spring&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;context&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;resource uri="config://spring/objects"/&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/context&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;objects&gt;    <br>&lt;!--这的配置根据实际的程序来的，UsersCompontents是程序集Spring.Demo.Compontext下的一个类--&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;object name="Users"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="Spring.Demo.Compontext.UsersCompontents,Spring.Demo.Compontent"&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/object&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/objects&gt;    <br>&nbsp;&nbsp;&nbsp; &lt;/spring&gt;    <br>&nbsp; &lt;/configuration&gt;    <br>&nbsp; 四.建立好项目的实体类和接口以及实现借口。    <br>&nbsp; 下面是实例程序的结构图：Model(实体层),Service(接口),Compontent(实现接口的业务逻辑),SimpleTest(测试)    <br><img alt="" src="1.jpg" border="0">    <br>&nbsp;&nbsp; 五.首先看看实体层的定义，我相信代码大家都看得懂就不多说了，直接贴上来。    <br>using System;    <br>&nbsp;&nbsp; using System.Collections.Generic;    <br>&nbsp;&nbsp; using System.Text;</p>  <p>&nbsp;&nbsp; namespace Spring.Demo.Model   <br>&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;    <br>&nbsp;&nbsp;&nbsp; /// 用户类    <br>&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp; public class Users    <br>&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 编号    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int _oid;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public int Oid    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return _oid; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { _oid = value; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 姓名    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string _name;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string Name    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return _name; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { _name = value; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 性别    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string _sex;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string Sex    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return _sex; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { _sex = value; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 年龄    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int _age;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public int Age    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return _age; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { _age = value; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp; }</p>  <p>&nbsp;&nbsp; 六.在看接口的定义   <br>using System;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using System.Collections.Generic;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using System.Text;    <br>namespace Spring.Demo.Service    <br>&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public interface IUsers    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 返回用户的详细信息的方法    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;returns&gt;&lt;/returns&gt;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string GetUserInfo();    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp; 七.实现接口方法的逻辑    <br>using System;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using System.Collections.Generic;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using System.Text;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using Spring.Demo.Service;    <br>&nbsp;&nbsp;&nbsp;&nbsp; using Spring.Demo.Model;</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp; namespace Spring.Demo.Compontext   <br>&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class UsersCompontents:IUsers    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public UsersCompontents()    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { }</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #region 获取用户信息   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string GetUserInfo()    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Users user = new Users();    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Oid = 1;    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Name = "Beniao";    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Sex = "Boy";    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Age = 25;</p>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return string.Format("编号：{0}---&gt;姓名：{1}---&gt;性别：{2}---&gt;年龄：{3}",   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Oid,    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Name,    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Sex,    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user.Age);    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp;&nbsp; }    <br>&nbsp;&nbsp;&nbsp; 八.通过Spring.net的IOC容器IApplicationContext从config文件中取得程序集信息和调用方法实现控制反转    <br>&nbsp;&nbsp;&nbsp;&nbsp; //从config文件中取得程序集信息    <br>&nbsp;&nbsp;&nbsp;&nbsp; IApplicationContext context =&nbsp; ConfigurationManager.GetSection("spring/context")&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as IApplicationContext;    <br>//调用方法    <br>&nbsp;&nbsp;&nbsp; //Users为config文件里的配置节    <br>&nbsp;&nbsp;&nbsp; //&lt;object name="Users"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="Spring.Demo.Compontext.UsersCompontents,Spring.Demo.Compontent"&gt;    <br>&nbsp;&nbsp;&nbsp; //&lt;/object&gt;    <br>&nbsp;&nbsp;&nbsp; IUsers user = context.GetObject("Users") as IUsers;    <br>Console.WriteLine(user.GetUserInfo());    <br>&nbsp;&nbsp;&nbsp; Console.Read();    <br>&nbsp;&nbsp;&nbsp; 运行结果如下：    <br><img alt="" src="2.jpg" border="0" height="434" width="540">    <br>&nbsp;&nbsp;&nbsp; 关于Spring.net的IOC容器就简单介绍在这里了，我也是刚学Spring.net，文章里难免会出现错误，目前    <br>&nbsp;&nbsp;&nbsp; Spring.net的人气太低了，希望对这有兴趣的朋友多多探讨，更希望这方面的高手能多指教。如文章中发现    <br>&nbsp;&nbsp;&nbsp; 错误希望大家留言提出，我门大家一起学习，改进。</p>
<div id="digg_block">
<div id="div_digg">										
	<div class="diggit" onclick="DiggIt(1595059,58766,1)"> 
		<span class="diggnum" id="digg_count_1595059">0</span>
	</div>
	<div class="buryit" onclick="DiggIt(1595059,58766,2)"> 
		<span class="burynum" id="bury_count_1595059">0</span>
	</div>
	<div class="clear"></div>
	<span style="display: none;" id="span_isdigged_1595059">0</span>	
	<div class="diggword" id="digg_word_1595059">(请您对文章做出评价)</div>	
</div>
</div>
<div class="clear"></div>
<div id="post_next_prev">
<a href="http://www.cnblogs.com/pursue/archive/2009/10/23/1588586.html">« </a> 上一篇：<a href="http://www.cnblogs.com/pursue/archive/2009/10/23/1588586.html" title="发布于2009-10-23 11:50">VS 技巧</a><br>
<a href="http://www.cnblogs.com/pursue/archive/2009/11/11/1600971.html">» </a> 下一篇：<a href="http://www.cnblogs.com/pursue/archive/2009/11/11/1600971.html" title="发布于2009-11-11 14:56">在.NET中使用命名管道完成进程间通信</a><br>
</div>








		</div>
		<div class="postDesc">posted @ 2009-11-03 11:00 <a href="http://www.cnblogs.com/pursue/">pursue</a> 阅读(9) <a href="#commentform">评论(0)</a> &nbsp;<a href="http://www.cnblogs.com/pursue/admin/EditArticles.aspx?postid=1595059">编辑</a> <a href="http://www.cnblogs.com/pursue/AddToFavorite.aspx?id=1595059">收藏</a> <a href="#" onclick="PutInWz();return false;">网摘</a>  </div>
	</div>
	<img src="1595059.html" height="1" width="1">
	
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.cnblogs.com/pursue/articles/1595059.html"
dc:identifier="http://www.cnblogs.com/pursue/articles/1595059.html"
dc:title=""
trackback:ping="http://www.cnblogs.com/pursue/services/trackbacks/1595059.aspx" />
</rdf:RDF>
-->

</div><!--end: topics 文章、评论容器-->

				
	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="profile_block"><a href="http://home.cnblogs.com/pursue/" target="_top">我的主页</a>&nbsp; <a href="http://home.cnblogs.com/pursue/detail/" target="_top">个人资料</a><br><a href="http://home.cnblogs.com/pursue/ing/" target="_top">我的闪存</a>&nbsp; <a href="http://space.cnblogs.com/msg/send/pursue" target="_top">发短消息</a></div>
</div>

			<div id="calendar"><table id="Calendar1_entryCal" class="Cal" title="Calendar" border="0" cellpadding="0" cellspacing="0">
	<tbody><tr><td colspan="7"><table class="CalTitle" border="0" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:__doPostBack('Calendar1$entryCal','V3622')" style="color: Black;" title="Go to the previous month">&lt;</a></td><td align="center">2010年1月</td><td class="CalNextPrev" align="right"><a href="javascript:__doPostBack('Calendar1$entryCal','V3684')" style="color: Black;" title="Go to the next month">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" abbr="日" scope="col" align="center">日</th><th class="CalDayHeader" abbr="一" scope="col" align="center">一</th><th class="CalDayHeader" abbr="二" scope="col" align="center">二</th><th class="CalDayHeader" abbr="三" scope="col" align="center">三</th><th class="CalDayHeader" abbr="四" scope="col" align="center">四</th><th class="CalDayHeader" abbr="五" scope="col" align="center">五</th><th class="CalDayHeader" abbr="六" scope="col" align="center">六</th></tr><tr><td class="CalOtherMonthDay" align="center">27</td><td class="CalOtherMonthDay" align="center">28</td><td class="CalOtherMonthDay" align="center">29</td><td class="CalOtherMonthDay" align="center">30</td><td class="CalOtherMonthDay" align="center">31</td><td align="center">1</td><td class="CalWeekendDay" align="center">2</td></tr><tr><td class="CalWeekendDay" align="center">3</td><td align="center">4</td><td align="center">5</td><td align="center">6</td><td align="center">7</td><td align="center">8</td><td class="CalWeekendDay" align="center">9</td></tr><tr><td class="CalWeekendDay" align="center">10</td><td align="center">11</td><td align="center">12</td><td align="center">13</td><td align="center">14</td><td align="center">15</td><td class="CalWeekendDay" align="center">16</td></tr><tr><td class="CalTodayDay" align="center">17</td><td align="center">18</td><td align="center">19</td><td align="center">20</td><td align="center">21</td><td align="center">22</td><td class="CalWeekendDay" align="center">23</td></tr><tr><td class="CalWeekendDay" align="center">24</td><td align="center">25</td><td align="center">26</td><td align="center">27</td><td align="center">28</td><td align="center">29</td><td class="CalWeekendDay" align="center">30</td></tr><tr><td class="CalWeekendDay" align="center">31</td><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td><td class="CalOtherMonthDay" align="center">3</td><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td></tr>
</tbody></table>
</div>
			
			<div id="leftcontentcontainer">
				

<div class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div class="div_my_zzk"><input value="" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk" type="text">&nbsp;<input onclick="zzk_go()" value="找找看" id="btnZzk" class="btn_my_zzk" type="button"></div>
</div>
<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>

		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl00_lnkLinkItem" href="http://www.cnblogs.com/pursue/MyPosts.html">我的随笔</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl01_lnkLinkItem" href="http://home.cnblogs.com/pursue/">我的空间</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl02_lnkLinkItem" href="http://space.cnblogs.com/msg/recent">我的短信</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl03_lnkLinkItem" href="http://www.cnblogs.com/pursue/MyComments.html">我的评论</a></li>
	
<li><a id="itemListLink" onclick="this.blur();WarpClass('itemListLink', 'itemListLin_con');return false;" href="#">更多链接</a></li>
</ul>
<div id="itemListLin_con" style="display: none;">
<ul>

		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl00_lnkLinkItem" title="我发表过评论的随笔" href="http://www.cnblogs.com/pursue/OtherPosts.html">我的参与</a></li>
	
		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl01_lnkLinkItem" href="http://www.cnblogs.com/pursue/MyNews.html">我的新闻</a></li>
	
		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl02_lnkLinkItem" href="http://www.cnblogs.com/pursue/tag/">我的标签</a></li>
	
</ul>
</div>
</div>
<div class="catListPostArchive">
<h3 class="catListTitle">随笔档案</h3>

<ul>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl01_Link" href="http://www.cnblogs.com/pursue/archive/2009/11.html">2009年11月 (2)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl02_Link" href="http://www.cnblogs.com/pursue/archive/2009/10.html">2009年10月 (3)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl03_Link" href="http://www.cnblogs.com/pursue/archive/2009/09.html">2009年9月 (55)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl04_Link" href="http://www.cnblogs.com/pursue/archive/2009/08.html">2009年8月 (30)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl05_Link" href="http://www.cnblogs.com/pursue/archive/2009/07.html">2009年7月 (1)</a> </li>

</ul>

</div>

<div class="catListArticleCategory">
<h3 class="catListTitle">文章分类</h3>

<ul>

<li><a id="SingleColumn1_Categories_CatList_ctl01_LinkList_ctl01_Link" href="http://www.cnblogs.com/pursue/category/220645.html">English</a> <a id="SingleColumn1_Categories_CatList_ctl01_LinkList_ctl01_RssLink" title="Subscribe to English" href="http://www.cnblogs.com/pursue/category/220645.html/rss">(rss)</a></li>

<li><a id="SingleColumn1_Categories_CatList_ctl01_LinkList_ctl02_Link" href="http://www.cnblogs.com/pursue/category/220646.html">PFS</a> <a id="SingleColumn1_Categories_CatList_ctl01_LinkList_ctl02_RssLink" title="Subscribe to PFS" href="http://www.cnblogs.com/pursue/category/220646.html/rss">(rss)</a></li>

</ul>

</div>



<div class="catListComment">
<h3 class="catListTitle">最新评论<a id="SingleColumn1__fff8ce_RSSHyperlink1" title="RSS订阅最最新评论" href="http://www.cnblogs.com/pursue/CommentsRSS.aspx"><img title="RSS订阅最最新评论" src="xml.gif" style="border-width: 0px;"></a></h3>

	
</div>

<div class="catListView">
<h3 class="catListTitle">阅读排行榜</h3>
	
			<ul>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/09/21/1570963.html">1.&nbsp;Ultraedit菜单字体修正(zhuan)(183)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/08/03/1537766.html">2.&nbsp;C#和Java的泛型、C++模板、C#的constraints特性以及弱类型化和强类型化的问题(转)(175)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/10/03/1577768.html">3.&nbsp;此安装不支持该项目类型 vs2008 webapplication(167)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/08/17/1548010.html">4.&nbsp;防范SQL注入攻击(147)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/08/14/1545730.html">5.&nbsp;C#中事务的应用实例(转）(139)</a>
			</li>
		
			</ul>
		
</div>

<div class="catListFeedback">
<h3 class="catListTitle">评论排行榜</h3>
	
			<ul>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/11/21/1607612.html">1.&nbsp;32位操作系统能支持4G以上内存原因(0)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/11/11/1600971.html">2.&nbsp;在.NET中使用命名管道完成进程间通信(0)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/10/23/1588586.html">3.&nbsp;VS 技巧(0)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/10/09/1579931.html">4.&nbsp;c# 4.0新特性一览(zhuan)(0)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/pursue/archive/2009/10/03/1577768.html">5.&nbsp;此安装不支持该项目类型 vs2008 webapplication(0)</a>
			</li>
		
			</ul>
		
</div>

			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2010 pursue
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->
    </form>
	
	
      
    
    
    
</body>
</html>
